<template>
  <div>
    <div id="box"></div>
  </div>
</template>

<script>
import * as echarts from "echarts";

export default {
  // 定义属性
  name: "About",
  data() {
    return {};
  },
  methods: {
    initEcharts() {
      var chartDom = document.getElementById("box");
      var myChart = echarts.init(chartDom);
      var option;

      option = {
        xAxis: {
          type: "category",
          data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: [150, 230, 224, 218, 135, 147, 260],
            type: "line",
          },
        ],
      };

      option && myChart.setOption(option);
    },
  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    this.initEcharts();
  },
};
</script>

<style lang='scss' scoped>
#box {
  width: 600px;
  height: 400px;
  background: red;
}
</style>